#ifndef _BBNAO_BNAO_H_
#define _BBNAO_BNAO_H_

#include <robot/robot.h>
#include <robot/sdh/enums.h>
#include <blackbox/bbox.h>
#include <blackbox/cdatain.h>
#include <blackbox/cdataout.h>
#include <blackbox/carrayin.h>
#include <blackbox/carrayout.h>
#include <blackbox/cmethod.h>

#include <buola/io/csocketacceptor.h>
#include <buola/xml.h>

#include <alproxies/altexttospeechproxy.h>
#include <alproxies/almotionproxy.h>
#include <alproxies/alrobotpostureproxy.h>

namespace buola { namespace robot { namespace nao {

using namespace buola;

class BNao : public blackbox::BBox
{
public:
    BNao();

private:
    void OnPullJoints();
    void SetGoal(const mat::CVecNd<26> &pJoints);
    void Speak();
    void Walk();
    void Posture(const std::string &pName);
    void Relax();
    
    AL::ALMotionProxy &MotionProxy();
    AL::ALTextToSpeechProxy &SpeechProxy();
    AL::ALRobotPostureProxy &PostureProxy();
    
public:
    blackbox::CArrayOut<double,blackbox::NPullOutput> oJoints;
    blackbox::CMethod<void(mat::CVecNd<26>)> mSetGoal;
    blackbox::CMethod<void()> mSpeak;
    blackbox::CMethod<void()> mWalk;
    blackbox::CMethod<void(std::string)> mPosture;
    blackbox::CMethod<void()> mRelax;

private:
    std::vector<double> mActual;
    
    std::mutex mMutex;
    
    std::unique_ptr<AL::ALMotionProxy> mMotionProxy;
    std::unique_ptr<AL::ALTextToSpeechProxy> mSpeechProxy;
    std::unique_ptr<AL::ALRobotPostureProxy> mPostureProxy;
    
    bool mWalking;
};

/*namespace nao*/ } /*namespace robot*/ } /*namespace buola*/ }

#endif
